import axios from 'axios'
import {
	getToken
} from '@/utils/auth'
import {
	Message,
	MessageBox
} from 'element-ui'
import Url from "@/utils/base";
let baseURL = Url.baseURL
// let baseURL = 'https://api.artube.cc'
// 创建axios实例
let service = axios.create({
	baseURL: baseURL, // api的 base_url
	timeout: 15000 // 请求超时时间
})

// 配置全局取消数组
window.__axiosPromiseArr = [];

// request拦截器
service.interceptors.request.use(config => {
    config.headers = {
		"token": getToken('Token'),
	};
	return config
}, error => {
	Promise.reject(error)
})

// respone拦截器
service.interceptors.response.use(
	response => {
		console.log(response.data.status!=200);
		if(response.data.status!=200){
			alert(response.data.data)
      this.$router.push('/login');
		}
		console.log('static',response);
		return response
	},
	error => {
		console.log('static',error);
		return Promise.reject(error)
	}
)

export default service